$(function() {
	$("#header").load('header.html', function() {
		loadHeader(2)
	});
	$("#footer").load('footer.html', function(data, status, xhr) {});
	$("#tab").load('tab.html', function(data, status, xhr) {});
	//获取url中的参数
	function getUrlParam(name) {
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
		var r = window.location.search.substr(1).match(reg); //匹配目标参数
		if(r != null) return unescape(r[2]);
		return null; //返回参数值
	}
	//接收URL中的参数booksId
	var id = getUrlParam('mid');
	//console.log(id);
	var _url = decodeURI(window.location.search)
    var condition = _url.split('=')[1]
	$.ajax({
		url: host + '/MtmlAPI/HospitalList',
		type: 'post',
		dataType: 'JSON',
		data: {
			cid: cid,
			index: 1,
			size: 100,
			lat: '32.07766',
			lng: '118.77158',
			isTop: false,
			condition:condition
		},

		success: function(res) {
			var obj = res.data
			if(res.state) {
				html = ''

				$.each(obj, function(i, tag) {
					var tagHtml = ''
					var tagArr = obj[i].Tags.split('|').slice(0, -2)
					$.each(tagArr, function(j, tag) {
						tagHtml += `<div>${tag}</div>`
					})
					html += `
               		<li onclick="location.href='hospital-detail.html?HosID=${tag.HosID}'">
               			<div class='hospital-img' style='background-image:url(${tag.HeadImage})'></div>
	               		<div class='hospital-txt'>
							<div class="hos-name">${tag.HosName}</div>
							<div class="hos-add">所在地：${tag.Address}</div>
							<div class="doc-proyecto">${tagHtml}</div>
						</div>
					</li>
				`
				});
				$('.hospital-list').append(html)
			} else {

			}
		},
		error: function() {}
	});

})